using System;
using System.IO;
using System.Xml;
using System.Collections.Generic;

namespace opt
{
	public class OptimizationConfiguration
	{
		private String _path;
		private Dictionary<String,String> _config;

		public String Path
		{
			get
			{
				return _path;
			}
		}

		public OptimizationConfiguration(String path)
		{
			_path = path;
			FileStream fs = new FileStream(path,FileMode.Open);
			XmlDocument xml = new XmlDocument();
			xml.Load(fs);
			LoadConfig(xml);
		}

		private void LoadConfig(XmlDocument xml)
		{
			_config = new Dictionary<String,String>();
			XmlNode root = xml.DocumentElement.SelectSingleNode("/config");
			foreach(XmlNode child in root.ChildNodes)
			{
				_config.Add(child.Name,child.InnerText);
			}
		}

		public String GetConfigValue(String name)
		{
			if(_config.ContainsKey(name))
				return _config[name];
			return "";
		}
	}
}
